package com.fly.toolbox.constant;

public enum BankEnum {

    init		("标准版本"),
    nbyh		("宁银理财"),
    hxiayh		("华夏银行"),
    zgyh		("中银理财"),
    czyh		("稠州银行"),
    bjyh		("北银理财"),
    hsyh		("徽银理财"),
    hongtyh		("红塔银行"),
    xyyh		("兴银理财"),
    hzyh		("杭银理财"),
    jtyh		("交银理财"),
    cdnsh		("成都农商行"),
    jiangsyh	("苏银理财"),
    ycyh		("中邮理财"),
    qdyh		("青银理财"),
    shnsh		("上海农商行"),
    hkyh		("汉口银行"),
    cqyh		("重庆银行"),
    dyyh		("东亚银行"),
    msyh		("民银理财"),
    njyh		("南银理财"),
    pzhyh		("攀枝花银行"),
    huasyh		("华商银行"),
    gyyh		("贵阳银行"),
    sylc		("上银理财"),
    qllc		("齐鲁理财"),

    // 不需要维护的银行
    shyh		("上海银行"),
    zhxt		("中航信托"),
    shnsmh		("上海农商母行"),
    qlyh		("齐鲁银行"),
    huifyh		("汇丰银行"),
    pfyh		("浦发银行");

    private String bankDesc;

    BankEnum(String bankDesc) {
        this.bankDesc = bankDesc;
    }

    public String getBankDesc() {
        return bankDesc;
    }

    public static String getBankName(String bankName) {
        for (BankEnum value : BankEnum.values()) {
            if (value.name().equals(bankName)) {
                return value.getBankDesc();
            }
        }
        return null;
    }

    public static String parseBankAlias(String taskBankName) {
        for (BankEnum value : BankEnum.values()) {
            if (taskBankName.contains(value.getBankDesc().substring(0,2))) return value.name();
        }
        return null;
    }

    public static boolean checkBankValid(String bankName) {
        return isValidBankEnum(bankName) && !isInvalidBank(bankName);
    }

    private static boolean isValidBankEnum(String bankName) {
        for (BankEnum value : BankEnum.values()) {
            if (value.name().equals(bankName)) {
                return true;
            }
        }
        return false;
    }

    private static boolean isInvalidBank(String bankName) {
        switch (bankName) {
            case "zhxt":
            case "pfyh":
            case "huifyh":
                return true;
            default:
                return false;
        }
    }


}
